#include "handle.h"

//IHandle
IHandle::IHandle()
{
	m_pthread = NULL;
}

IHandle::~IHandle()
{
	SAFE_FREE_POINT(m_pthread);
}

void IHandle::go(handle h)
{
	m_pthread = new thread(h, this);
	m_pthread->detach();
}

//CollectHandle
void CollectHandle::go(handle h, int i)
{
	m_pthread = new thread(h, this, i);
	m_pthread->detach();
}
//--CollectHandle

void MuxerHandle::go(handle h, enum muxHandleType type)
{
	if (MUX_AUDIO == type)
	{
		m_thread2[0] = new thread(h, this);
		m_thread2[0]->detach();
	}
	else if (MUX_VIDEO == type)
	{
		m_thread2[1] = new thread(h, this);
		m_thread2[1]->detach();
	}
}

MuxerHandle::MuxerHandle() 
{
	m_thread2[0] = NULL;
	m_thread2[1] = NULL;
}

MuxerHandle::~MuxerHandle()
{
	SAFE_FREE_POINT(m_thread2[0]);
	SAFE_FREE_POINT(m_thread2[1]);
}

VCaptureHandle::VCaptureHandle()
{
	m_thread2[0] = NULL;
	m_thread2[1] = NULL;
}

VCaptureHandle::~VCaptureHandle()
{
	SAFE_FREE_POINT(m_thread2[0]);
	SAFE_FREE_POINT(m_thread2[1]);
}

void VCaptureHandle::go(handle h)
{
	if (m_thread2[0] == NULL)
	{
		m_thread2[0] = new thread(h, this);
		m_thread2[0]->detach();
	}
	else if (m_thread2[1] == NULL)
	{
		m_thread2[1] = new thread(h, this);
		m_thread2[1]->detach();
	}
}